/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Trp_socio_ecoDAOImpl implements orm.dao.Trp_socio_ecoDAO {
	public Trp_socio_eco loadTrp_socio_ecoByORMID(String so_id_socio_e) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return loadTrp_socio_ecoByORMID(session, so_id_socio_e);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco getTrp_socio_ecoByORMID(String so_id_socio_e) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return getTrp_socio_ecoByORMID(session, so_id_socio_e);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByORMID(String so_id_socio_e, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return loadTrp_socio_ecoByORMID(session, so_id_socio_e, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco getTrp_socio_ecoByORMID(String so_id_socio_e, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return getTrp_socio_ecoByORMID(session, so_id_socio_e, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByORMID(PersistentSession session, String so_id_socio_e) throws PersistentException {
		try {
			return (Trp_socio_eco) session.load(orm.Trp_socio_eco.class, so_id_socio_e);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco getTrp_socio_ecoByORMID(PersistentSession session, String so_id_socio_e) throws PersistentException {
		try {
			return (Trp_socio_eco) session.get(orm.Trp_socio_eco.class, so_id_socio_e);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByORMID(PersistentSession session, String so_id_socio_e, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Trp_socio_eco) session.load(orm.Trp_socio_eco.class, so_id_socio_e, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco getTrp_socio_ecoByORMID(PersistentSession session, String so_id_socio_e, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Trp_socio_eco) session.get(orm.Trp_socio_eco.class, so_id_socio_e, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco[] listTrp_socio_ecoByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return listTrp_socio_ecoByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco[] listTrp_socio_ecoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return listTrp_socio_ecoByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco[] listTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Trp_socio_eco as Trp_socio_eco");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Trp_socio_eco[]) list.toArray(new Trp_socio_eco[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco[] listTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Trp_socio_eco as Trp_socio_eco");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Trp_socio_eco[]) list.toArray(new Trp_socio_eco[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return loadTrp_socio_ecoByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return loadTrp_socio_ecoByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Trp_socio_eco[] trp_socio_ecos = listTrp_socio_ecoByQuery(session, condition, orderBy);
		if (trp_socio_ecos != null && trp_socio_ecos.length > 0)
			return trp_socio_ecos[0];
		else
			return null;
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Trp_socio_eco[] trp_socio_ecos = listTrp_socio_ecoByQuery(session, condition, orderBy, lockMode);
		if (trp_socio_ecos != null && trp_socio_ecos.length > 0)
			return trp_socio_ecos[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTrp_socio_ecoByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return iterateTrp_socio_ecoByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTrp_socio_ecoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Basededatosv5PersistentManager.instance().getSession();
			return iterateTrp_socio_ecoByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Trp_socio_eco as Trp_socio_eco");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTrp_socio_ecoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Trp_socio_eco as Trp_socio_eco");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco createTrp_socio_eco() {
		return new orm.Trp_socio_eco();
	}
	
	public boolean save(orm.Trp_socio_eco trp_socio_eco) throws PersistentException {
		try {
			orm.Basededatosv5PersistentManager.instance().saveObject(trp_socio_eco);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Trp_socio_eco trp_socio_eco) throws PersistentException {
		try {
			orm.Basededatosv5PersistentManager.instance().deleteObject(trp_socio_eco);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Trp_socio_eco trp_socio_eco)throws PersistentException {
		try {
			orm.Trp_colegio[] lTrp_colegios = trp_socio_eco.trp_colegio.toArray();
			for(int i = 0; i < lTrp_colegios.length; i++) {
				lTrp_colegios[i].setSocio_eco(null);
			}
			return delete(trp_socio_eco);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Trp_socio_eco trp_socio_eco, org.orm.PersistentSession session)throws PersistentException {
		try {
			orm.Trp_colegio[] lTrp_colegios = trp_socio_eco.trp_colegio.toArray();
			for(int i = 0; i < lTrp_colegios.length; i++) {
				lTrp_colegios[i].setSocio_eco(null);
			}
			try {
				session.delete(trp_socio_eco);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Trp_socio_eco trp_socio_eco) throws PersistentException {
		try {
			orm.Basededatosv5PersistentManager.instance().getSession().refresh(trp_socio_eco);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Trp_socio_eco trp_socio_eco) throws PersistentException {
		try {
			orm.Basededatosv5PersistentManager.instance().getSession().evict(trp_socio_eco);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Trp_socio_eco loadTrp_socio_ecoByCriteria(Trp_socio_ecoCriteria trp_socio_ecoCriteria) {
		Trp_socio_eco[] trp_socio_ecos = listTrp_socio_ecoByCriteria(trp_socio_ecoCriteria);
		if(trp_socio_ecos == null || trp_socio_ecos.length == 0) {
			return null;
		}
		return trp_socio_ecos[0];
	}
	
	public Trp_socio_eco[] listTrp_socio_ecoByCriteria(Trp_socio_ecoCriteria trp_socio_ecoCriteria) {
		return trp_socio_ecoCriteria.listTrp_socio_eco();
	}
}
